package exam;

import java.util.Scanner;

public class test5 {

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        int q=in.nextInt();

        int [][]nums=new int[n][m];
        for (int i = 0; i <n ; i++) {
            for (int j = 0; j <m ; j++) {
                nums[i][j]=in.nextInt();
            }
        }
long dp[][]=new long[n+1][m+1];
        for (int i = 1; i <=n ; i++) {
            for (int j = 1; j <=m ; j++) {
                dp[i][j]=dp[i-1][j]+dp[i][j-1]+nums[i-1][j-1]-dp[i-1][j-1];
            }
        }

        while(q>0){
            int x1=in.nextInt();
            int y1=in.nextInt();
            int x2=in.nextInt();
            int y2=in.nextInt();
            long ans=dp[x2][y2]-dp[x2][y1-1]-dp[x1-1][y2]+dp[x1-1][y1-1];
            System.out.println(ans);
            q--;
        }
    }


    public int pivotIndex(int[] nums) {
long []dp=new long[nums.length+1];
        for (int i = 1; i <=dp.length ; i++) {
         dp[i]=dp[i-1]+nums[i-1];
        }
       int left=1;
        int right=dp.length;

        while(left<right){
            int mid=left+(right-left)/2;
            if(dp[mid]*2+dp[mid]<dp[dp.length-1]){
left=mid+1;
            }else {
                right=mid;
            }
        }
        if (dp[left-1]*2+dp[left]<dp[dp.length-1]){
            return left;
        }
        return -1;
    }




    public static void main4(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int q=in.nextInt();
        long[]dp=new long[n+1];
        dp[0]=0;
        for(int i=1;i<=n;i++){
            int tmp=in.nextInt();
            dp[i]=tmp+dp[i-1];
        }

        while(q>0){
            int l=in.nextInt();
            int r=in.nextInt();
            System.out.println(dp[r]-dp[l-1]);
            q--;
        }
    }

    public static int tribonacci(int n) {
        if(n==0){
            return 0;
        }
        if(n==1||n==2){
            return 1;
        }
        int []arr=new int[n+1];
        arr[0]=0;
        arr[1]=1;
        arr[2]=1;

        for(int i=3;i<=n;i++){
            arr[i]=arr[i-1]+arr[i-2]+arr[i-3];
        }
        return arr[n];
    }


    public static void main2(String[] args) {
        int []records={0,1,2,3,5};
        System.out.println(takeAttendance(records));
    }

    public static int takeAttendance(int[] records) {
        int left=0,right=records.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(records[mid]==mid){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return records[left]==left?left+1:left;
    }

    public static int takeAttendance1(int[] records) {
        int left=0,right=records.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(records[mid]==mid+1){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return left+1;
    }


    public static void main1(String[] args) {
int []nums={4,5,6,7,0,1,2};
        System.out.println(findMin(nums));

    }

    public static int findMin(int[] nums) {
        int left=0;
        int right=nums.length-1;
        int x=nums[right];
        while(left<right){
            int mid=left+(right-left)/2;
            if(nums[mid]>x){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return nums[left];
    }



    public int findPeakElement(int[] nums) {
        int left=0,right=nums.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(nums[mid]<nums[mid+1]){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return left;
    }


    public int peakIndexInMountainArray(int[] arr) {
        int left=0;
        int right=arr.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(arr[mid]>arr[mid+1]){
                right=mid;
            }else{
                left=mid+1;
            }
        }
        return left;

    }


    public int mySqrt(int x) {
        long left=0;
        long right=x;
        while(left<right){
            long mid=left+(right-left+1)/2;
            if(mid*mid<=x){
                left=mid;
            }else{
                right=mid-1;
            }
        }
        return (int)left;
    }


    public int searchInsert(int[] nums, int target) {
        int left=0;
        int right=nums.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(nums[mid]<target){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        if(nums[left]<target){
            return left+1;
        }
        return left;
    }


    public int[] searchRange(int[] nums, int target) {
        int[]ret={-1,-1};
        if(nums==null){
            return ret;
        }
        int left=0;
        int right=nums.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(nums[mid]<target){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        if(nums[left]==target){
            ret[0]=left;
        }
        right=nums.length-1;
        while(left<right){
            int mid=left+(right-left+1)/2;
            if(nums[mid]<=target){
                left=mid;
            }else{
                right=mid-1;
            }
        }
        if(target==nums[left]){
            ret[1]=left;
        }
        return ret;
    }

}
